package edu.ycu.aladdin.web.service.impl;

import edu.ycu.aladdin.web.common.OauthChannel;
import edu.ycu.aladdin.web.dao.OauthDao;
import edu.ycu.aladdin.web.dto.User;
import edu.ycu.aladdin.web.service.LoginService;
import edu.ycu.aladdin.web.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * @author <a href="mailto:wangruihuano@gmail.com">王瑞环</a>
 * @since 1.0
 */
@Service
public class UserServiceIml implements UserService {

    private static final Logger logger = LoggerFactory.getLogger(UserServiceIml.class);


    private final LoginService loginService;

    private final OauthDao oauthDao;

    public UserServiceIml(LoginService loginService, OauthDao oauthDao) {
        this.oauthDao = oauthDao;
        this.loginService = loginService;
    }

    @Override
    public User login(OauthChannel channel, Object info) {
        User user = loginService.login(channel, info);
        return oauthDao.login(user);
    }


}
